<template >
  <div v-if="userRole==='admin'"><h2>请{{userName}}严格维护墨韵教育系统用户数据</h2></div>
  <div v-else-if="userRole==='student'">
    <h2>近十次成绩折线图</h2>
    <ScoreChart :records="gradeData" />
  </div>
  <div v-else-if="userRole==='teacher'"><h2>欢迎{{userName}}老师使用墨韵教育系统</h2></div>
</template>
<script setup>
const userRole=JSON.parse(localStorage.getItem('userInfo')).role
const userId=JSON.parse(localStorage.getItem('userInfo')).userId
const userName=JSON.parse(localStorage.getItem('userInfo')).username
import { ref, onMounted, onBeforeUnmount, watch } from 'vue';
import {GetStudent} from '../../api/dashboard.js'
import ScoreChart from './ScoreChart.vue'


const gradeData = ref([])
const search=()=>{
  if (userRole==='student'){
    GetStudent({
      studentId:userId
    }).then(res=>{
      gradeData.value=res.data.data.records
    })
  }else if (userRole==='teacher'){

  }
}
onMounted(() => {
  search()
})
</script>
<style lang="less" scoped>

</style>
